import React from 'react'
import Header from '../../components/header'
import Footer from '../../components/footer'
import CnodeAPi from '../../api'
import {navs} from '../../store'

export default class PostPage extends React.Component {
  static async getInitialProps (ctx) {
    // console.log(ctx)
    const result = await CnodeAPi.getPostDetail({postId: ctx.query.postId})

    return {
      query: ctx.query,
      post: result.data.data,
      navs
    }
  }
  render () {
    const post = this.props.post
    return (
      <div>
        <Header navs={this.props.navs} />
        <div className="m-container main-container" style={{marginTop: '30px'}}>
          <div className="m-row">
            <div className="m-col-md-1">
            </div>
            <div className="m-col-md-10">
              <div className="post-detail">
                <h1>{post.title}</h1>
                {/* {JSON.stringify(this.props)} */}
                <div className="post-content" dangerouslySetInnerHTML={{__html: post.content}}></div>
              </div>
            </div>
            <div className="m-col-md-1">
            </div>
          </div>
        </div>
        <Footer />
      </div>
    )
  }
} 
